[#ftl]
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>[#assign module]a/${_site_}/channels[/#assign][#assign moduleName="栏目"]
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>添加新${moduleName}</title>
<script type="text/javascript" src="${base}/commonjs/jquery1.7.2/jquery-1.7.2.min.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery-forms.js"></script>
<script type="text/javascript" src="${base}/commonjs/jquery.select.js"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/artDialog.source.js?skin=blue"></script>
<script type="text/javascript" src="${base}/commonjs/artDialog4/plugins/iframeTools.source.js"></script>
<style>
.main{
    height: 300px;
}
.main iframe { width:100%; height:100%;}
</style>
<script type="text/javascript">
function onTypeChange(){
    if(+$("#select_type").val()<=3){
        $("#div_bgurl").hide();
    }else{
        $("#div_bgurl").show();
    }
}
$(function(){
    $("#select_type").createSelect([[1, "标准列表栏目类型"], [2, "单页栏目类型"], [3, "半异构标准栏目类型"], [4, "半异构单页栏目类型"], [5, "纯异构栏目类型"]], ${(item.type)!0}).change(function(){
        onTypeChange();
    });
    onTypeChange();
    $("#select_parent").createSelect("${base}/a/${_site_}/channels/list", {}, function(row){
        return [row.id, row.cell[1]+"["+row.cell[0]+"]"];
    },  ${(item.parent.id)!0});
[#if (item.id)??][#else]
    $("#select_template_channels").createSelect("${base}/a/${_site_}/channels/templatechannels", {}, function(row){
        return [row.id, row.cell[1]+"["+row.cell[0]+"]"];
    },  ${(item.parent.id)!0});
[/#if]
  $("#btadditem").bind("click", function(){
    $("#additemform").ajaxForm({
      dataType: "json",
      success: function(json){
        if(!json.success){
          art.dialog.through({
            title: "[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]失败",
            icon: "error",
            content: "[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]失败！<br>"+json.err,
            width: 250,
            height: 150,
            background: '#EEE', // 背景色
            opacity: 0.05,  // 透明度
            lock: true,
            ok: true
          });
        }else{
          try{
             art.dialog.alert("信息保存成功！");
          }catch(e){
          }
        }
      }
    });
  });
});
</script>
</head>
<body>
<h3>[#if (item.id)??]编辑${moduleName}信息[#else]添加新${moduleName}[/#if]</h3>
<form id="additemform" action="${base}/${module}/${((item.id)??)?string('edit','add')}" method="POST">
<input type="hidden" name="id" value=${(item.id)!0}>
${moduleName}名:<input type="text" name="name" value="${(item.name)!}"/><br>
描述:<textarea rows="3" cols="35" name="description">${(item.description)!}</textarea><br>
path:<input type="text" name="path" value="${(item.path)!}"><br>
配套图片:<span id="pathSpan">${(item.image.path)!}</span>
<input type="hidden" id="inputImageId" name="image.id" value="${(item.image.id)!}">
<span><input type="file" name="file" onchange="uploadImage(this)"></span><br>

type:<select id="select_type" name="type">
<option value="0">容器栏目类型</option>
</select>
<br>
<div id="div_bgurl">
后台管理地址:<input type="text" name="backgroundURI" value="${(item.backgroundURI)!}">
</div>
parent:
<select id="select_parent" name="parent.id">
<option value="0">--请选择parent--</option>
</select><br>
[#if (item.id)??][#else]
<select id="select_template_channels" name="tempchid">
<option value="0">--请选择模板栏目--</option>
</select><br>
[/#if]
<input type="submit" value="保存新${moduleName}" id="btadditem">
</form>
<div class="main">
   <iframe id="ifr_main" name="ifr_main" frameborder="0" src="${base}/a/${_site_}/channels/${_channel_}/templatecfgs/index.html"></iframe>
</div>
<div style="position: absolute; width: 1px; height: 1px; left: -1000px; top: -1000px">
<form id="fileupload" action="${base}/uploadfile" method="POST" enctype="multipart/form-data" target="_fui">
    <input type="hidden" name="callback" value="setArticleImage">
    <div id="filecontainer"></div>
</form>
<iframe name="_fui"></iframe>
<script type="text/javascript">
function uploadImage(file){
    var span = $(file).parent();
    $(file).appendTo($("#filecontainer"));
    span.append($('<input type="file" name="file" onchange="uploadSnaptee(this);">'));
    $("#fileupload").submit();
    $("#btadditem").attr("disabled", true);
}
function setArticleImage(json){
    $("#filecontainer").html("");
    $("#pathSpan").html(json.origin);
    $("#inputImageId").val(json.id);
    $("#btadditem").attr("disabled", false);
}
</script>
</body>
</html>